package com.ruoyi.rpt.controller;

import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.rpt.service.IRptViewerService;

/**
 * 报表查看Controller
 * 
 */
@RestController
@RequestMapping("/rpt/viewer")
public class RptViewerController extends BaseController
{
    @Autowired
    private IRptViewerService rptViewerService;

    /**
     * 执行报表查询
     */
    // @RequiresPermissions("rpt:viewer:execute")
    @GetMapping("/{reportId}")
    public AjaxResult executeReport(
            @PathVariable("reportId") Long reportId,
            @RequestParam Map<String, Object> params)
    {
        return rptViewerService.executeReport(reportId, params);
    }

    /**
     * 导出报表数据
     */
    // @RequiresPermissions("rpt:viewer:export")
    @GetMapping("/export/{reportId}")
    public void exportReportData(
            HttpServletResponse response,
            @PathVariable("reportId") Long reportId,
            @RequestParam Map<String, Object> params)
    {
        rptViewerService.exportReportData(response, reportId, params);
    }
} 